//
//  CommonCell.m
//  Supermarket
//
//  Created by qskj-ios on 2018/12/10.
//  Copyright © 2018年 com.qiansheng. All rights reserved.
//

#import "CommonCell.h"

@implementation CommonCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    [self customBorderWithSize:kSeparatorHeight andPosition:UIViewBorderPositionBottom andColor:kSeparatorColor andLeadingInset:10 andTrailingInset:0];

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setContentWithLease:(LeaseModel *)model {
    self.titleLabel.text = model.goods_name;
    
    self.nameLabel.text = [NSString stringWithFormat:@"%@ %@", model.user_name, model.user_mobile];
    self.timeLabel.text = model.date;
    self.scoreLabel.text = [NSString stringWithFormat:@"押%@分", model.cost];
    if (model.sta == 0) {
        [self.retureButton setTitle:@"租赁" forState:UIControlStateNormal];
        [self.retureButton setBackgroundColor:RGB_COLOR(30, 194, 137)];
        [self.titleLabel setTextColor:kTextColorOne];
    } else if (model.sta == 1) {
        [self.retureButton setTitle:@"已租赁" forState:UIControlStateNormal];
        [self.retureButton setBackgroundColor:RGB_COLOR(30, 194, 137)];
        [self.titleLabel setTextColor:kTextColorOne];
    } else if (model.sta == 2) {
        [self.retureButton setTitle:@"已归还" forState:UIControlStateNormal];
        [self.retureButton setBackgroundColor:RGB_COLOR(222, 222, 222)];
        [self.titleLabel setTextColor:kTextColorThree];
    }
}

- (void)setContentWithBook:(BookModel *)model {
    self.titleLabel.text = model.book_name;
    
    self.nameLabel.text = [NSString stringWithFormat:@"%@ %@", model.user_name, model.user_mobile];
    self.timeLabel.text = model.borrow_date;
    self.scoreLabel.text = [NSString stringWithFormat:@"押%@分", model.cost];
    if (model.sta == 0) {
        [self.retureButton setTitle:@"未归还" forState:UIControlStateNormal];
        [self.retureButton setBackgroundColor:RGB_COLOR(30, 194, 137)];
        [self.titleLabel setTextColor:kTextColorOne];
    } else if (model.sta == 1) {
        [self.retureButton setTitle:@"已归还" forState:UIControlStateNormal];
        [self.retureButton setBackgroundColor:RGB_COLOR(222, 222, 222)];
        [self.titleLabel setTextColor:kTextColorThree];
    }
}

- (IBAction)didClickedRetureButton:(id)sender {
    if (self.retureButtonBlock) {
        self.retureButtonBlock(self);
    }
}

@end
